#include<iostream>
#include<algorithm>
using namespace std;

const int MAX_N = 1010;
const double EPS = 1e-5;
int main(int argc, char const *argv[])
{
    freopen("test.txt","r",stdin);
    double poly[2][MAX_N]={0};
    // input
    for(int i = 0;i<=1;++i)
    {
        int K; cin>>K;
        for(int j = 0;j<K;++j)
        {
            int id;double val; cin>>id>>val;
            poly[i][id] = val;
        }
    }
    double res[MAX_N] = {0};
    int cnt=0;
    for(int i = 0;i<MAX_N;++i)
    {
        res[i] = poly[0][i]+poly[1][i];
        if(res[i] > EPS || res[i] < -EPS)
            cnt++;
    }
    cout<<cnt;
    for(int i = MAX_N-1;i>=0;--i)
    {
        if(res[i] > EPS || res[i] < -EPS)
            { printf(" %d %.1f",i,res[i]); }
    }
    return 0;
}
